<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>隐藏</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>

<body>
    <p>X</p>
    <div></div>

    <script>
        var p = document.querySelector('p');
        var div = document.querySelector('div')
        p.onclick = function () {
            div.style.display = 'none'
        }
    </script>

</body>

</html>